{% extends 'common.html'%}
    {% block content %}

        <form class="layui-form">
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                 <span class="we-red">*</span>功能名称
                 </label>
                <div class="layui-input-inline env_tools layui-form">
                      <select id="business" name="business" lay-filter="business" required="" lay-verify="required" lay-search="">
                          <option value="">请选择</option>
                          {% for business in businesslist %}
                             <option value="{{ business.business_code}}">{{ business.business_name }}</option>
                          {% endfor %}
                      </select>
                    <input type="hidden" name="name" id="name">
                 </div>
            </div>
            <div class="layui-form-item">
                <label for="type" class="layui-form-label">
                 功能类型
                 </label>
                <div class="layui-input-block">
                    <select id="type" name="type" lay-filter="type" required="" lay-verify="required" >
                          <option value="">请选择</option>
                          <option value="mysql">mysql</option>
                          <option value="redis">redis</option>
                          <option value="post">post</option>
                          <option value="put">put</option>
                          <option value="get">get</option>
                      </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="var1" class="layui-form-label">
                 变量1
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="var1" name="var1" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="var2" class="layui-form-label">
                 变量2
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="var2" name="var2"  autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="var3" class="layui-form-label">
                 变量3
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="var3" name="var3"  autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="var4" class="layui-form-label">
                 变量4
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="var4" name="var4"  autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="pre" class="layui-form-label">
                 前置处理
                 </label>
                <div class="layui-input-block">
                    <textarea id="pre" name="pre" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="content" class="layui-form-label">
                 功能代码
                 </label>
                <div class="layui-input-block">
                    <textarea id="content" name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="post" class="layui-form-label">
                 后置处理
                 </label>
                <div class="layui-input-block">
                    <textarea id="post" name="post" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="sort" class="layui-form-label">
                 排序
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="sort" name="sort"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
		</form>


        <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>

        <script>
            layui.extend({
				admin: '/static/js/admin'
			});
			layui.use(['form','jquery', 'layer'], function() {
				var form = layui.form,
					$ = layui.jquery,
					layer = layui.layer;
				//监听提交
                form.on('select(business)', function(data){
                    $('#name').val($('#business').find("option:selected").text());
                });
				form.on('submit(add)', function(data) {
					$.ajax({
                        type: 'post',
                        url: '/admin/business_step_add',
                        data: data.field,
                        success: function(data) {
                            layer.msg(data.message);
                            if(data.code ==1){
                               var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                            }

                        }
                    });
					return false;
				});

			});
        </script>

    {% endblock %}